<?php
use phpmailer\phpmailer;
use think\Db;

    //求任意两个数之间的和
    function  summ($a,$b){
        $sum=0;
        for ($i=$a;$i<=$b;$i++){
             $sum += $i;

        }
        return $sum;
    }

        //求任意两个数之间的偶数和
      function summ_j($a,$b){
          $sum = 0;
          for ($i=$a;$i<=$b;$i++){
              if($i%2 == 0){
                  $sum += $i;
              }
          }
          return $sum;
      }
      //求任意两个数之间的奇数的和
        function summ_o($a,$b){
          $sum = 0;
          for ($i=$a;$i<=$b;$i++){
              if($i%2 >0){
                  $sum += $i;
              }
          }
            return $sum;
        }
        //回收列表
        function recycle($table){
            $data = Db::name($table)->where('is_del=1 and sign="pc"')->select();
            return $data;
        }
        //恢复
         function  recovery($table,$id){
             $result = Db::name($table)->where('id',$id)->update(['is_del'=>0]);
             return $result;
         }
         //删除
        function recycleDel($table,$id){
            $result = Db::name($table)->where('id',$id)->delete();
            return $result;
        }
        //通过某个键的value 分组
        function groupBycolumn($tar, $key)
        {
         $res = array();
            foreach ($tar as $v) {
             if (isset($res[$v[$key]])) {
                 $res[$v[$key]][] = $v;
            } else {
                $res[$v[$key]] = array($v);
            }
        }
        return $res;

        function checkDate($date){
            $ext = false;
            $date_now=date('j',$date); //得到是几号
            $cal_result=ceil($date_now/7); //计算是第几个星期几
            $month = date('%Y-%m',$date);//得到是几月
            $sql ="SELECT CEIL(FROM_UNIXTIME(ps_time,\'%d\')/7) zhou, FROM  `dh_works`  WHERE FROM_UNIXTIME(ps_time,'%Y-%m)=".$month;



            $week = Db::name('works')->query($sql);
            if(in_array($cal_result,$week)){
                $ext = true;
            }
                return $ext;

        }

        //生成文章链接的方法


}




